import instance from "./request";

// 获取商品管理列表

function goodsAdministration(data) {
    return instance.get(`categories`,{params:{type:data.type,pagenum:data.pagenum,pagesize:data.pagesize,}});
}
// 添加商品分类
function addGoodsCategory(data) {
    return instance.post(`categories`,data);
}
//删除商品分类
function deleteGoodsCategory(id) {
    return instance.delete(`categories/${id}`)
}
// 确定编辑 商品分类
function editGoodsCategory(id,data) {
    return instance.put(`categories/${id}`,{cat_name:data.cat_name,});
}

// 获取参数列表
function parameterList(data) {
    return instance.get(`categories/${data.id}/attributes`,{params:{sel:data.sel}});
}

// 添加参数列表
function addParameterList(data) {
    return instance.post(`categories/${data.id}/attributes`,{attr_name:data.attr_name,attr_sel:data.attr_sel});
}
// 删除参数列表
function deleteParameterList(id,attr_id) {
    return instance.delete(`categories/${id}/attributes/${attr_id}`)
}
// 编辑参数列表
function editParameterList(data) {
    let {attr_name,attr_sel,attr_vals} =data
    return  instance.put(`categories/${data.id}/attributes/${data.attrId}`,{attr_name,attr_sel,attr_vals})
}
// 商品管理
// 商品列表数据
function goodsList(data) {
    return instance.get(`goods`,{params:{pagenum:data.pagenum,pagesize:data.pagesize,}});
}
// 添加商品
function addGoods(data) {
    return instance.post(`goods`,{...data});
}
// 删除商品
function deleteGoods(id) {
    return instance.delete(`goods/${id}`)
}

// 数据图统计
function gitrepotr(id) {
    return instance.get(`reports/type/1`)
}

export{
    goodsAdministration,
    addGoodsCategory,
    deleteGoodsCategory,
    editGoodsCategory,
    parameterList,
    addParameterList,
    deleteParameterList,
    editParameterList,
    goodsList,
    addGoods,
    deleteGoods,
    gitrepotr

}